<template>
  <view class="content">
    <view class="home-swiper">
      <u-swiper
        img-mode="scaleToFill"
        :list="banner"
        @click="toBanner"
      ></u-swiper>
    </view>
    <view class="home-post" v-if="system_post.length > 0">
      <u-notice-bar
        mode="horizontal"
        :list="system_post"
        type="none"
        color="#EF2E1C"
      ></u-notice-bar>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      banner: [
        "https://img1.baidu.com/it/u=3539595421,754041626&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
        "https://img1.baidu.com/it/u=3539595421,754041626&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
      ],
      system_post: ["公告公告公告公告公告公告"],
    };
  },
  created() {},
  methods: {
    async getBanner() {
      let res = await this.$u.api.getBanner();
      if (res.code == 1) {
        if (res.data) {
          this.banner = [];
          res.data.forEach((e) => {
            this.banner.push([e.url]);
          });
        }
      }
    },
    async getPost() {
      let res = await this.$u.api.getPost();
      if (res.code == 1) {
        if (res.data) {
          this.system_post = [];
          res.data.forEach((e) => {
            this.system_post.push([e.content]);
          });
        }
      }
    },
    async getUserInfo() {
      let res = await this.$u.api.getUserInfo();
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  text-align: center;
  height: 400upx;
}
.home {
  &-swiper {
    margin: 20rpx 20rpx 0rpx 20rpx;
  }
  &-post {
    margin: 20rpx 20rpx 0rpx 20rpx;
    background-color: $card-backgroud-color;
    border-radius: 10rpx;
  }
}
</style>
